#include <iostream>

using namespace std;
using ll=long long;
const int N=1e5+10;

ll a[N];
ll b[N];
ll c[N];
int n,m;

int lowbit(int x)
{
	return -x&x;
}
void insert(ll s[],int pos,int x)
{

	for(int i=pos;i<=n;i+=lowbit(i))
	{
		s[i]+=x;
	}
}
ll query(ll s[],int x)
{
	ll ret=0;
	for(int i=x;i;i-=lowbit(i))
	{
		ret+=s[i];
	}
	return ret;
}

int main()
{
	
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{

		scanf("%lld",&c[i]);
		insert(a,i,c[i]);
		insert(b,i,i*c[i]);
	}
	
	while(m--)
	{
		string op;
		ll l;
		cin>>op>>l;
		if(op[0]=='Q')
		{
			printf("%lld\n",(l+1)*query(a,l)-query(b,l));
		}
		else if(op[0]=='M'){
			ll num;
			scanf("%lld",&num);
			insert(a,l,num-c[l]);
			insert(b,l,l*(num-c[l]));
			c[l]=num;
		
		}
	}
//	cout<<query(a,5)<<endl;
//	cout<<query(f,5)<<endl;
	return 0;
}
//1 3 6 10 15
//1 4 10 20 35

//1 2 2 4 5
//1 3 5 9 14
//1 4 9 18 32
